// 将某一个独立的功能做成一个函数，让它在组件加载的过程中可以触发
import { useCallback, useEffect, useRef } from "react";
export default function useMountedState() {
    const mountedRef = useRef(false);
    const get = useCallback(() => {
        return mountedRef.current;
    })

    useEffect(() => {
        mountedRef.current = true;
        return () => {
            mountedRef.current = false;
        }
    }, [])

}